home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / COMMUNIC / 0576.ZIP / STAYSAVE.420 < prev    next >
Text File  |  1986-08-06  |  5KB  |  73 lines

  1. Inline(
  2.                               {;****************************************************************************;}
  3.                               {;                 S  T  A  Y  S  A  V  E  .  I  N  C                         ;}
  4.                               {;****************************************************************************;}
  5.                               {;Version 4.15}
  6.                               {;}
  7.                               {; This Inline routine will save the regs and Stack for Stay resident programs.}
  8.                               {; It restores DS and SS from the previously saved integer constants "OurDseg"}
  9.                               {; and "OurSSeg".  DS is restored from the Turbo Initialization Savearea.}
  10.                               {; Author: Copyr. 1985, 1986}
  11.                               {;                Lane Ferris}
  12.                               {;              - The Hunter's Helper -}
  13.                               {;       Distributed to the Public Domain for use without profit.}
  14.                               {;                    Original Version 5.15.85}
  15.   $FA                         {       CLI                       ; Stop all interrupts}
  16.   /$2E                        {       CS:}
  17.   /$80/$0E/>STATUS/<INUSE     {       Or by   [<Status],<InUse  ; Set Active bit}
  18.                               {; Switch the SS:Sp reg pair over to ES:Si}
  19.                               {; Put Turbo's Stack pointers into SS:Sp}
  20.   /$2E                        {       CS:}
  21.   /$8C/$1E/>USRDSEG           {       Mov     [>UsrDSeg],DS        ; Save Usr DataSegment}
  22.   /$2E                        {       CS:}
  23.   /$8C/$16/>USRSSEG           {       Mov     [>UsrSSeg],SS        ; Save Usr Stack Segment}
  24.   /$2E                        {       CS:}
  25.   /$89/$26/>USRSPTR           {       Mov     [>UsrSPtr],Sp        ; Save Usr Stack Ptr}
  26.                               {; Stack User interrupted pgm regs for Exit.}
  27.                               {; These are the original interrupt process regs}
  28.                               {; that must be returned on interrupt return}
  29.   /$2E                        {       CS:}
  30.   /$8E/$1E/>OURDSEG           {       Mov     DS,[>OurDseg] ; Get Turbo Stack pointer from DataSegment}
  31.   /$2E                        {       CS:}
  32.   /$8E/$16/>OURSSEG           {       Mov     SS,[>OurSSeg]}
  33.   /$8B/$26/$74/$01            {       Mov     Sp,[$174]    ; Sp set by code at $B2B in Turbo initialization}
  34.   /$55                        {       Push    Bp}
  35.   /$50                        {       Push    Ax}
  36.   /$53                        {       Push    Bx}
  37.   /$51                        {       Push    Cx}
  38.   /$52                        {       Push    Dx}
  39.   /$56                        {       Push    Si}
  40.   /$57                        {       Push    Di}
  41.   /$06                        {       Push    Es}
  42.                               {; Save the InDOS stack to avoid recursion crashes (Writeln).}
  43.                               {; Setup destination to Turbo Stack}
  44.   /$89/$E7                    {       Mov     Di,Sp  ;Dest is our stack}
  45.   /$4F                        {       Dec     Di     ;Back off current used word}
  46.   /$4F                        {       Dec     Di}
  47.   /$2E                        {       CS:}
  48.   /$8C/$D0                    {       Mov     Ax,SS  ;Turbo stack is destination}
  49.   /$8E/$C0                    {       Mov     ES,Ax}
  50.                               {; Setup source from DOS Indos primary stack}
  51.   /$2E                        {       CS:}
  52.   /$8E/$1E/>DOSSSEG           {       Mov     DS,[>DosSSeg]   ; Source is DOS Indos primary stack}
  53.   /$2E                        {       CS:}
  54.   /$8B/$36/>DOSSPTR           {       Mov     Si,[>DosSptr]   ; DOS primary stack offset}
  55.   /$B9/$40/$00                {       Mov     Cx,$40}
  56.   /$2E                        {       CS:}
  57.   /$89/$0E/>DOSSSIZ           {       Mov     [>DosSsiz],Cx ;remember the stack word size}
  58.   /$4E                        {       Dec     Si     ;point last word on stack}
  59.   /$4E                        {       Dec     Si}
  60.   /$89/$E0                    {       Mov     Ax,Sp           ;Get stack pointer higher to avoid}
  61.   /$29/$C8                    {       Sub     Ax,Cx           ;overwriting during enabled REP functions}
  62.   /$29/$C8                    {       Sub     Ax,Cx}
  63.   /$89/$C4                    {       Mov     Sp,Ax}
  64.   /$FD                        {       STD            ;Move like Pushes on stack}
  65.   /$F2/$A5                    {       Rep Movsw      ;Move users stack to our own}
  66.   /$89/$FC                    {       Mov     Sp,Di  ;Update our stack pointer to available word.}
  67.   /$FC                        {       Cld}
  68.   /$2E                        {       CS:}
  69.   /$8E/$1E/>OURDSEG           {       Mov     DS,[>OurDSeg]   ; Setup Turbo Data Segment Pointer}
  70.   /$FB                        {       STI                     ; Enable Interrupts}
  71.                               {;...........................................................................}
  72. );
  73.